﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Web.Core
{
    public class StringHash
    {
        public string Name;
        public string Value;
    }

    public class JsonFormat
    {
        List<StringHash> lt;

        public JsonFormat(string json)
        {
            lt = new List<StringHash>();
            try
            {
                lt = Newtonsoft.Json.JavaScriptConvert.DeserializeObject<List<StringHash>>(json);
            }
            catch
            {
                lt = null;
            }
        }

        public string GetValue(string key)
        {
            string temp;
            if (lt == null)
                return null;
            for (int i = 0; i < lt.Count; i++)
            {
                temp = lt[i].Name.ToUpper().Trim();
                if (temp == key.ToUpper().Trim())
                    return lt[i].Value;
            }
            return null;
        }
    }
}